<?php 


class Character extends xObject
 {
 
	function __construct()
	{		
		xObject::__construct(core::getWorldSQL(),"characters",MYSQL_WORLD_DB_CHARACTERS ) ;

	}
	
	function setAtLoginFlag($flag)
	{
		$this->at_login = $flag ;
		$this->lock(); //on verrouille
		$this->setPKey("guid");
		$this->setWriteAttribute($this->guid);
		//echo "writeattrref: ".$this->writeAttrRef ;
		$this->unlock_attribute("at_login");
		$this->write();
		
	}
	
	function setRace($race)
	{
		$this->race = $race;
		$this->lock(); //on verrouille
		$this->setPKey("guid");
		$this->setWriteAttribute($this->guid);
		//echo "writeattrref: ".$this->writeAttrRef ;
		$this->unlock_attribute("race");
		$this->write();
	}
	
	function isGM()
	{
		$this->sql_link->select_db(MYSQL_AUTH_DB);
		$exec = $this->sql_link->query("SELECT SQL_CACHE * FROM account_access WHERE id = '".$this->account."'");
		if(!$exec->num_rows) return false;
		else return true;
	}
	
	function getGuildName()
	{
		$query = "SELECT SQL_CACHE guildid FROM guild_member WHERE guid = '".$this->guid."'";
		//echo $query;
		$exec = $this->sql_link->query($query);
		if(!$exec->num_rows) return false;
		else
		{
			
			$result = $exec->fetch_object();
			$query2 = "SELECT SQL_CACHE * FROM guild WHERE guildid = '".$result->guildid."'";
			
			$exec2 = $this->sql_link->query($query2);
			$result2 = $exec2->fetch_object();
		
			return "< ".$result2->name." >";
		}
	}
 }

?>